﻿@{
    ViewBag.Title = "Location";
    Layout = "~/Views/Shared/_Layout.cshtml";
    ViewBag.MenuId = "locationLink";
}
@section HeadSection
{
    @*Injects css into the layout page*@
    <link href="@Url.Content("~/Content/Location.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/jquery.treeview.css")" rel="stylesheet" type="text/css" />
    <link href="../../Content/themes/base/jquery-ui.css" rel="Stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-ui.js" type="text/javascript"></script>
}
<script type="text/javascript" src="../../Scripts/jquery.treeview.js"></script>
<script type="text/javascript">

    $(document).ready(function () {
        $("#treeview").treeview();
        var curNodeId = "#@ViewBag.TreeId";
        $(curNodeId).addClass("selectedNode");

    }
    )
</script>
<h3>
    Location Management</h3>
<div class="leftBar">
    @{Metro.Kashikoi.ServiceContract.Location.Organization org = ViewBag.Organization;}
    @* a treeview using JQuery Plugin http://docs.jquery.com/Plugins/Treeview*@
    <ul id="treeview" class="filetree">
        @*Root level*@
        <li><span class="folder"><a class="root" href="/Location/Root" title="Click to view all inventories in root" id=@("root_" + @org.Id)>@org.Name</a></span>
            <ul>
                @foreach (var facilityLevel in org.Facilities)
                {       //facility Level
                    <li><span class="folder"><a class="" href="/Location/Facility/@facilityLevel.Id" title="Click to view all inventories in this facility" id=@("facility_" + facilityLevel.Id)>
                        @facilityLevel.Name</a> </span>
                        <ul>
                            @foreach (var unit in facilityLevel.Units)
                            {//Unit level
                                <li><span class="folder"><a  class= "" href="/Location/Unit/@unit.Id" title="Click to view all inventories in this unit" id=@("unit_" + @unit.Id) >
                                    @unit.Name</a> </span>
                                    <ul>
                                        @foreach (var area in unit.StockAreas)
                                        { //Area level
                                            <li><span class="file"><a href="/Location/StockArea/@area.Id" title="Click to view inventories in this area" id=@("stockarea_" + @area.Id) >
                                                @area.Name </a></span></li>
                                        }
                                    </ul>
                                </li>
                            }
                        </ul>
                    </li>
                }
            </ul>
        </li>
    </ul>
</div>
<div class="rightBar" style="padding: 5px">
    @RenderSection("RightBar", required: true)
</div>
<div class="content">
    @RenderBody()
</div>
<div style="clear: both">
</div>
